//
//  BuyDetailViewController.m
//  YunGou
//
//  Created by macbook on 16/5/20.
//  Copyright © 2016年 macbook. All rights reserved.
//

#import "BuyDetailViewController.h"
#import "NSString+DateTransform.h"
#import "NSString+Frame.h"
#import "NoMoreDataView.h"

@interface BuyDetailViewController ()

@end

@implementation BuyDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NoMoreDataView *footerView = [[NoMoreDataView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
    self.tableView.tableFooterView = footerView;
    // Do any additional setup after loading the view.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = nil;
    if (indexPath.row == 0) {
        cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
        UILabel *goodsName = [cell viewWithTag:1];
        goodsName.text = _productModel.title;
        UILabel *qihao = [cell viewWithTag:2];
        qihao.text = [NSString stringWithFormat:@"参与期号：%@",_productModel.qishu];
        UILabel *partakeNum = [cell viewWithTag:3];
        partakeNum.text = _productModel.gonumber;
    }else if (indexPath.row == 1){
        cell = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
    }else{
        cell = [tableView dequeueReusableCellWithIdentifier:@"cell3"];
        UILabel *timeLabel = [cell viewWithTag:1];
        timeLabel.text = [NSString timeTransformWithString:[NSString stringWithFormat:@"%lf",_productModel.q_end_time] andFormatter:@"yyyy-MM-dd\nHH:mm:ss"];
        UILabel *partakeNum = [cell viewWithTag:2];
        partakeNum.text = _productModel.gonumber;
        UILabel *totalNum = [cell viewWithTag:3];
        totalNum.text = [NSString stringWithFormat:@"%ld",_productModel.zongrenshu];
    }return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        CGFloat height = [_productModel.title heightWithFont:[UIFont systemFontOfSize:16] withinWidth:ScreenWidth - 32];
        return 85 - 19 + height;
    }return 44;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
